package com.foreveross.project.projectonline.service;
import java.util.List;
import javax.inject.Named;
import org.apache.commons.lang3.StringUtils;
import com.foreveross.project.projectonline.model.Project;
@Named("projectService")
public class ProjectService {

	public List<Project> selectProjectByContition() {

		List<Project> products = Project.dao
				.find("select * from TD_OL_PROJECT ");

		return products;

	}
	
	public String createProject(Project project){
		if(isEmpty(project.get("NAME"))){
			return "创建项目失败，项目名称不能为空！";
		}
		//project.set("CREATE_TIME", new Date());
		if(project.save()){
			return "项目创建成功";
		}else{
			return "创建失败，请联系管理员！";
		}
	}
	
	public boolean isEmpty(Object obj){
		return obj==null||StringUtils.isEmpty(obj.toString());
	}
	
	public boolean deleteProject(String id){
		return Project.dao.deleteById(id);
	}
	
	public Project getProjectById(String id){
		return Project.dao.findById(id);
	}
	
}
